﻿@using Ebusiness_Authservice.Services.Dtos
@model LoginRequest

@{
    ViewData["Title"] = "用户登录";
}

<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h4>用户登录</h4>
                </div>
                <div class="card-body">
                    <!-- 成功消息显示 -->
                    @if (TempData["SuccessMessage"] != null)
                    {
                        <div class="alert alert-success">
                            @TempData["SuccessMessage"]
                        </div>
                    }

                    <form method="post" action="@Url.Action("Login", "Auth")">
                        <input type="hidden" name="returnUrl" value="@ViewBag.ReturnUrl" />

                        <div class="form-group mb-3">
                            <label for="Username">用户名</label>
                            <input type="text" id="Username" name="Username" class="form-control" required />
                            <span asp-validation-for="Username" class="text-danger"></span>
                        </div>

                        <div class="form-group mb-3">
                            <label for="Password">密码</label>
                            <input type="password" id="Password" name="Password" class="form-control" required />
                            <span asp-validation-for="Password" class="text-danger"></span>
                        </div>

                        @if (!ViewData.ModelState.IsValid)
                        {
                            <div class="alert alert-danger">
                                @foreach (var error in ViewData.ModelState.Values.SelectMany(v => v.Errors))
                                {
                                    <p>@error.ErrorMessage</p>
                                }
                            </div>
                        }

                        <div class="d-grid">
                            <button type="submit" class="btn btn-primary">登录</button>
                        </div>
                    </form>

                    <div class="mt-3 text-center">
                        <p>还没有账户？ <a href="@Url.Action("Register", "Auth")">立即注册</a></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>